package com.lsh.oms.provider.service.payment;

import com.alibaba.dubbo.config.annotation.Service;
import com.alibaba.dubbo.rpc.protocol.rest.support.ContentType;
import com.lsh.base.common.model.CommonResult;
import com.lsh.oms.api.service.payment.IOrderSignForRefundFilterRestService;
import com.lsh.oms.core.constant.ReturnCode;
import com.lsh.oms.core.service.payment.OrderSignForRefundService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

/**
 * Project Name: OrderSignForRefundFilterRestService
 * 北京链商电子商务有限公司
 * @author wangliutao
 * Date: 18/6/7
 * Package Name: com.lsh.oms.provider.service.payment
 * Description:业务背景:
 *      1、订单预付款,即在线支付
 *      2、用户在签收时, 该订单是创建部分捡缺、发货部分捡缺、部分返仓、全单返仓; 从而导致的退款
 *      3、部分签收触发退款的请求,只有在返仓确定时申请(允许重复申请,覆盖上一条记录)
 */
@Service(protocol = "rest", timeout = 30000)
@Path("order/refund")
@Consumes({MediaType.APPLICATION_JSON})
@Produces({ContentType.APPLICATION_JSON_UTF_8})
public class OrderSignForRefundFilterRestServiceImpl implements IOrderSignForRefundFilterRestService {
    private static final Logger logger = LoggerFactory.getLogger(OrderSignForRefundFilterRestServiceImpl.class);

    @Autowired
    private OrderSignForRefundService orderSignForRefundService;

    @GET
    @Path("partionSign")
    @Override
    public CommonResult<String> orderSignForRefund(@QueryParam("orderCode") Long orderCode) {
        logger.info("【签收--check】 param --> orderCode: {}", orderCode);
        CommonResult<String> commonResult = new CommonResult<>();
        try {
//            this.orderSignForRefundService.orderSignForRefund(orderCode);

            commonResult.setCode(ReturnCode.REQUEST_SUCCESS);
            commonResult.setMessage("success");
        } catch (Exception e) {
            logger.error("【签收--check】 orderCode: " + orderCode + ",异常信息: " + e.getMessage(),e);

            commonResult.setCode(ReturnCode.REQUEST_FAIL);
            commonResult.setMessage(e.getMessage());
        }

        return commonResult;
    }

}
